<template>
	<view class="bf h100v">
		<view class="f-c-c p3">
			<view class="mb20 mt90">
				<view class="wei t-c f32" @click="a">验证取货码</view>
				<view class="f-row p3">
					<input class="input p02 f30" v-model="params.selfCode" placeholder="请输入核销码" />
					<button :disabled="loading" @click="qrhx" class="f-c c0 f30" style="border-radius: 0 10rpx 10rpx 0;padding: 0 40rpx;" :style="{ background: ztqs }">核销</button>
				</view>
			</view>
			<view class="slaforder" @click="go({ t: 1, url: '/yb_shd/dp/self-ext-order' })">
				<text>{{ system.selfCount }}个待自提订单</text>
				<uni-icons type="arrowright" color="#2b85e4" size="28"></uni-icons>
			</view>
			<view class="bf5 mt20" style="width: 750rpx;height: 20rpx;"></view>
			<view class="f-c-c mt90">
				<view class="wei f32 mb30">扫码核销</view>
				<!-- <view class="imgc">
					<mg-img src='/static/img/dp/1.png'></mg-img>
				</view> -->
				<text @click="smhx" class="iconfont iconhx" style="font-size: 220rpx;" :style="{ color: tColor }"></text>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState, mapActions } from 'vuex';
import { scanCode } from '@/common/wechat-util.js';
import utils from '@/common/utils.js';
import jzz from '@/components/common/jzz.vue';
export default {
	name: 'order-index',
	components: {
		jzz
	},
	data() {
		return {
			loading: false,
			params: {
				selfCode: '',
				type: 'verification'
			}
		};
	},
	onLoad(options) {
		// this.getSystem()
		this.util.setNT('核销自提订单');
	},
	computed: {
		...mapState(['system']),
		ztqs() {
			return `linear-gradient(90deg, ${utils.jjldColor(this.tColor,40)}, ${this.tColor})`
		},
	},
	methods: {
		a(){
			console.log('公共信息：',this.system)
		},
		async qrhx() {
			if (utils.failValue(this.params.selfCode)) return this.util.message('请输入取货码', 3);
			try {
				await this.util.modal('确认核销?');
			} catch (e) {
				return;
			}
			this.loading = true;
			let res = await this.util
				.request({
					url: this.api.ddcz,
					method: 'POST',
					mask: 1,
					data: this.params
				})
				.catch(e => {
					this.loading = false;
				});
			if (res) {
				this.params.selfCode = ''; //清空请求url前缀
				this.util.message('核销成功', 3);
				this.loading = false;
			}
		},
		async smhx() {
			let res = await scanCode();
			if (res) {
				this.go({
					url: 'hx?t=1&code=' + encodeURIComponent(JSON.stringify(res.result))
				});
			}
		}
	}
};
</script>
<style scoped lang="scss">
.input {
	height: 2.8em;
	min-height: 2.8em;
	line-height: 2.8em;
	border: 1px solid #c0c4cc;
	border-radius: 10rpx 0 0 10rpx;
	border-right: none;
}

.imgc {
	width: 220rpx;
	height: 220rpx;
}
.slaforder {
	color: #2b85e4;
}
</style>
